<template>
  <div class="layout-all">
    <control :config="config" />
    <div class="layout-header" style="float:left">
      <!-- <router-link to="/user_abt/user/form">
        <el-button
          type="primary"
          icon="el-icon-plus"
          style="margin-left:0px"
        >添加</el-button>
          icon="el-icon-check"
      </router-link> -->
    </div>
    <div class="layout-content">
      <el-table
        :data="tableData"
        stripe
        align="center"
        highlight-current-row
        style="margin-top:50px"
        @selection-change="handleSelectionChange"
      >
        <!-- <el-table-column
          type="selection"
          width="55"
        /> -->
        <el-table-column align="center" prop="id" label="序号" width="80" />
        <el-table-column align="center" prop="create_time" label="创建日期" width="200"  />
        <el-table-column align="center" prop="account" label="账号"  />
        <el-table-column align="center" prop="nickname" label="昵称"  />
        <el-table-column align="center" prop="contact" label="联系人"  />
        <el-table-column align="center" prop="content" label="内容" />
        <el-table-column align="center" prop="picture" label="图片" >
          <template slot-scope="scope">
            <img :src="scope.row.picture" width="100">
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          prop="telephone"
          fixed="right"
          width="180"
          label="操作"
        >
          <template slot-scope="scope">
            <el-button
              size="small"
              type="danger"
              icon="el-icon-delete"
              @click="onDel(scope.row.id)"
            />
          </template>
        </el-table-column>
      </el-table>
    </div>
    <el-pagination
      :current-page="current_page"
      :page-size="per_page"
      layout="total, prev, pager, next, jumper"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script>
import control from '../../components/control/control'
export default {
  name:'feed_back_index',
  components: { control },
  data() {
    return {
      config: [
        { type: 'text', placeholder: '请输入联系人/账号', field: 'title', val: '' }
      ],
      searchWhere: {
        title: ''
      },
      tableData: [],
      total: 0,
      current_page: 1,
      per_page: 14,
      rules: {
        reply_remark: [
          { required: true, message: '请输入回复备注', trigger: 'blur' }
        ]
      }
    }
  },
  activated(){
    // if(this.$getUpdate()){
      this.onSearch()
    // }
  },
  created() {
    this.onSearch()
  },
  methods: {
    // 查询
    handleSelectionChange(val) {
      this.selection = []
      val.forEach(e => {
        this.selection.push(e.id)
      })
    },
    handleSizeChange(val) {
      this.onSearch()
    },
    handleCurrentChange(val) {
      this.current_page = val
      this.onSearch()
    },
    onSearch() {
      const form = {}
      form.page = this.current_page
      form.map = this.searchWhere
      this.get('/admin/Feedback/index', form, 'POST').then(e => {
        this.tableData = e.list.data
        this.per_page = e.list.per_page
        this.total = e.list.total
        this.current_page = e.list.current_page
      })
    },
    // 添加
    onAdd() {},
    // 编辑
    onEdit(id) {
      console.log(id)
    },
    // 删除
    onDel(id) {
      this.$confirm('是否删除该记录', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.get('/admin/Feedback/del?id=' + id, this.form, 'POST').then(e => {
          this.onSearch()
          this.$message({
            type: 'success',
            message: '删除成功!'
          })
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    }
  }
}
</script>

<style>
.layout-all {
  margin-top: 20px;
  margin-left: 10px;
}
.layout-content {
  margin-top: 20px;
}
</style>>
